#include <stdio.h>
#include <windows.h>
#include "websocket_packet_parsing.h"

int main(void)
{
	char buf[500] = {
"123fdsFsFDasd4324HTTP/1.1 200 OK\r\n\
Server: openresty\r\n\
Date: Wed, 09 Nov 2016 08:29:47 GMT\r\n\
Content-Type: application/json\r\n\
Content-Length: 56\r\n\
Connection: keep-alive\r\n\
\r\n\
{\"error\":0,\"reason\":\"ok\",\"IP\":\"54.223.34.73\",\"port\":443}56468"};

	char str[300] = {0x81,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9E};
	uint8_t *s = "{\"error\":404,\"reason\":\"Not Found\",\"deviceid\":\"10000294df\",\"apikey\":\"4328c6f4-577e-493c-8cfa-9c7fdd1fef2c\",\"config\":{\"regInterval\":15},\"actionName\":\"register\"}";
	uint8_t src[200] = {0};
	uint8_t test[10] = "1234";
	int i = 0;
	
	for(i=0;i<158;i++)
	{	
		str[i + 10] = s[i];
	}

	if (check_websocket_packet_rece_finish(str, 168) == TRUE)
	{
		i = get_websocket_packet_head(str, WEBSOCKET_FIN_RSV);
		printf("%x ", i);
		i = get_websocket_packet_head(str, WEBSOCKET_OPCODE);
		printf("%x ", i);
		i = get_websocket_packet_head(str, WEBSOCKET_MASK);
		printf("%x ", i);
		i = get_websocket_packet_head(str, WEBSOCKET_PAYLOAD_LEN);
		printf("%x ", i);
		i = get_websocket_packet_head(str, WEBSOCKET_MASK_KEY);
		printf("%x ", i);
		i = get_websocket_packet_head(str, WEBSOCKET_EXTENDED_PAYLEN);
		printf("%x\n", i);
		get_websocket_packet_data(str, src);
		printf("%s", src);
	}

	i = atoi(test);
	printf("%d\n", i);

	while (1)
	{

	}
}